<div class="wrapper">

    {menu}

    <section class="content">
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">
                    <div class="view-header">
                        <div class="header-title">
                            <h3 class="m-b-xs">Settings</h3>
                            <small>The admin settings page allows you to customize and configure various aspects of the ezXSS platform.</small>
                        </div>
                    </div>
                    <hr>
                </div>
            </div>

            {message}

            <div class="row">

                <div class="col-lg-6">
                    <div class="panel panel-filled">
                        <div class="panel-heading">Application settings</div>
                        <div class="panel-body">
                            <form class="form" method="post">
                                <input type=hidden hidden name="csrf" value="{session[csrfToken]}">
                                <div class="form-group">
                                    <label class="control-label" for="timezone">Timezone</label>
                                    <select class="form-control" name="timezone">
                                        {%foreach timezone}
                                        {timezone->html}
                                        {%/foreach}
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label class="control-label" for="theme">Theme</label>
                                    <select class="form-control" name="theme">
                                        {%foreach theme}
                                        {theme->html}
                                        {%/foreach}
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label class="control-label" for="filter">On callback if report is duplicate</label>
                                    <select class="form-control" id="filter" name="filter">
                                        <option {%data filter1} value="1">Both save report and send alert</option>
                                        <option {%data filter2} value="2">Only save report</option>
                                        <option {%data filter3} value="3">Only send alert</option>
                                        <option {%data filter4} value="4">Don't save report or send alert</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label class="control-label" for="dompart">Max DOM length in alerts</label>
                                    <input class="form-control" name="dompart" type="text" value="{%data dompart}">
                                </div>
                                <div class="form-group">
                                    <label class="checkbox-label">
                                        <input {%checked logging} class="chkbox" name="loggingon" type="checkbox">
                                        <span class="checkbox-custom rectangular"></span>
                                    </label>
                                    <p class="checkbox-text">Enable logging</p>
                                </div>
                                <button name="application" type="submit" class="btn">Save</button>
                            </form>
                        </div>
                    </div>

                    <div class="panel panel-filled">
                        <div class="panel-heading">Global payload settings</div>
                        <div class="panel-body">
                            <p>Each payload can choose their own options, but only the onces allowed here</p>
                            <form class="form" id="collecting" method="post">
                                <input type=hidden hidden name="csrf" value="{session[csrfToken]}">
                                <div class="row">
                                    <div class="col-lg-6">
                                        <div class="form-group">
                                            <label class="checkbox-label">
                                                <input {%checked collect_uri} class="chkbox" name="uri" type="checkbox">
                                                <span class="checkbox-custom rectangular"></span>
                                            </label>
                                            <p class="checkbox-text">URL</p>
                                            <label class="checkbox-label">
                                                <input {%checked collect_ip} class="chkbox" name="ip" type="checkbox">
                                                <span class="checkbox-custom rectangular"></span>
                                            </label>
                                            <p class="checkbox-text">IP</p>
                                            <label class="checkbox-label">
                                                <input {%checked collect_referer} class="chkbox" name="referer"
                                                    type="checkbox">
                                                <span class="checkbox-custom rectangular"></span>
                                            </label>
                                            <p class="checkbox-text">Referer</p>
                                            <label class="checkbox-label">
                                                <input {%checked collect_user-agent} class="chkbox" name="user-agent"
                                                    type="checkbox">
                                                <span class="checkbox-custom rectangular"></span>
                                            </label>
                                            <p class="checkbox-text">User Agent</p>
                                            <label class="checkbox-label">
                                                <input {%checked collect_cookies} class="chkbox" name="cookies"
                                                    type="checkbox">
                                                <span class="checkbox-custom rectangular"></span>
                                            </label>
                                            <p class="checkbox-text">Cookies</p>
                                        </div>
                                    </div>
                                    <div class="col-lg-6">
                                        <div class="form-group">
                                            <label class="checkbox-label">
                                                <input {%checked collect_localstorage} class="chkbox"
                                                    name="localstorage" type="checkbox">
                                                <span class="checkbox-custom rectangular"></span>
                                            </label>
                                            <p class="checkbox-text">Local Storage</p>
                                            <label class="checkbox-label">
                                                <input {%checked collect_sessionstorage} class="chkbox"
                                                    name="sessionstorage" type="checkbox">
                                                <span class="checkbox-custom rectangular"></span>
                                            </label>
                                            <p class="checkbox-text">Session Storage</p>
                                            <label class="checkbox-label">
                                                <input {%checked collect_dom} class="chkbox" name="dom" type="checkbox">
                                                <span class="checkbox-custom rectangular"></span>
                                            </label>
                                            <p class="checkbox-text">DOM</p>
                                            <label class="checkbox-label">
                                                <input {%checked collect_origin} class="chkbox" name="origin"
                                                    type="checkbox">
                                                <span class="checkbox-custom rectangular"></span>
                                            </label>
                                            <p class="checkbox-text">Origin</p>
                                            <label class="checkbox-label">
                                                <input {%checked collect_screenshot} class="chkbox" name="screenshot"
                                                    type="checkbox">
                                                <span class="checkbox-custom rectangular"></span>
                                            </label>
                                            <p class="checkbox-text">Screenshot</p>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="control-label" for="customjs">Custom javascript</label>
                                    <small>Add custom javascript which will be added to <i>all</i> payloads</small>
                                    <textarea class="form-control" name="customjs" rows=5>{%data customjs}</textarea>
                                </div>

                                <div class="form-group">
                                    <label class="checkbox-label">
                                        <input {%checked persistent} class="chkbox" name="persistenton" type="checkbox">
                                        <span class="checkbox-custom rectangular"></span>
                                    </label>
                                    <p class="checkbox-text">Allow enabling of persistent mode</p>
                                </div>

                                <button name="global-payload" type="submit" class="btn">Save</button>
                            </form>
                        </div>
                    </div>

                    <div class="panel panel-filled">
                        <div class="panel-heading">Kill Switch</div>
                        <div class="panel-body">
                            <p>Completely kills the platform. Can be reverted by visiting
                                https://{domain[]}/?pass=...
                            </p>
                            <form class="form" method="post">
                                <input type=hidden hidden name="csrf" value="{session[csrfToken]}">
                                <div class="form-group">
                                    <label class="control-label" for="password">Password to revert</label>
                                    <input class="form-control" name="password" type="text">
                                </div>
                                <button name="killswitch" type="submit" class="btn">Kill</button>
                            </form>
                        </div>
                    </div>

                </div>


                <div class="col-lg-6">

                    <div class="panel panel-filled">
                        <div class="panel-heading">Global alert settings</div>
                        <div class="panel-body">
                            <form class="form" method="post">
                                <input type=hidden hidden name="csrf" value="{session[csrfToken]}">
                                <div class="form-group">
                                    <label class="control-label" for="method">How do you want to receive alerts for all
                                        payloads</label>
                                    <select class="form-control" id="method" name="method">
                                        <option selected></option>
                                        <option value="1">E-mail</option>
                                        <option value="2">Telegram</option>
                                        <option value="3">Slack</option>
                                        <option value="4">Discord</option>
                                    </select>
                                </div>

                                <div id="method-pick">
                                    Pick an option
                                </div>

                                <div id="method-content-1" class="method-content">

                                    <label class="checkbox-label">
                                        <input {%checked mailAll} class="chkbox" name="mailon" type="checkbox">
                                        <span class="checkbox-custom rectangular"></span>
                                    </label>
                                    <p class="checkbox-text">Enable global email alerts</p>

                                    <div class="form-group">
                                        <label class="control-label">Send mail to</label>
                                        <input type="text" name="mail" class="form-control" value="{%data email}">
                                    </div>
                                    <button name="global-alert" type="submit" class="btn">Save</button>

                                </div>

                                <div id="method-content-2" class="method-content">

                                    <label class="checkbox-label">
                                        <input {%checked telegramAll} class="chkbox" name="telegramon" type="checkbox">
                                        <span class="checkbox-custom rectangular"></span>
                                    </label>
                                    <p class="checkbox-text">Enable global Telegram alerts</p>

                                    <div class="form-group">
                                        <label class="control-label" for="telegram_bottoken">Bot Token</label>
                                        <div class="input-group">
                                            <input class="form-control" name="telegram_bottoken" id="telegram_bottoken"
                                                placeholder="1234567890:AAbcd1234qZylg5bEzXsSjCGqro_Vb8XcM" type="text"
                                                value="{%data telegramToken}">
                                            <span class="input-group-addon"><a id="openGetChatId">Get
                                                    chatID</a></span>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label">Chat ID</label>
                                        <input type="text" name="chatid" id="chatid" class="form-control"
                                            placeholder="123456789" value="{%data telegramChatID}">
                                    </div>
                                    <button name="global-alert" type="submit" class="btn">Save</button>

                                </div>

                                <div id="method-content-3" class="method-content">

                                    <label class="checkbox-label">
                                        <input {%checked slackAll} class="chkbox" name="slackon" type="checkbox">
                                        <span class="checkbox-custom rectangular"></span>
                                    </label>
                                    <p class="checkbox-text">Enable global Slack alerts</p>

                                    <div class="form-group">
                                        <label class="control-label">Webhook URL</label>
                                        <input type="text" name="slack_webhook" class="form-control"
                                            placeholder="https://hooks.slack.com/services/T00000000/B00000000/XXXX..."
                                            value="{%data slackWebhook}">
                                    </div>
                                    <button name="global-alert" type="submit" class="btn">Save</button>

                                </div>

                                <div id="method-content-4" class="method-content">

                                    <label class="checkbox-label">
                                        <input {%checked discordAll} class="chkbox" name="discordon" type="checkbox">
                                        <span class="checkbox-custom rectangular"></span>
                                    </label>
                                    <p class="checkbox-text">Enable global Discord alerts</p>

                                    <div class="form-group">
                                        <label class="control-label">Webhook URL</label>
                                        <input type="text" name="discord_webhook" class="form-control"
                                            placeholder="https://discordapp.com/api/webhooks/1038928198292..."
                                            value="{%data discordWebhook}">
                                    </div>

                                    <button name="global-alert" type="submit" class="btn">Save</button>

                                </div>

                                <div id="method-disabled" class="method-content">

                                    <p>This alerting option is currently not enabled, first enable this.
                                    </p>

                                </div>
                            </form>
                        </div>
                    </div>

                    <div class="panel panel-filled">
                        <div class="panel-heading">Enable alerting methods</div>
                        <div class="panel-body">
                            <form class="form" method="post">
                                <input type=hidden hidden name="csrf" value="{session[csrfToken]}">

                                <label class="checkbox-label">
                                    <input {%checked alert-mail} class="chkbox" name="mailon" type="checkbox">
                                    <span class="checkbox-custom rectangular"></span>
                                </label>
                                <p class="checkbox-text">Enable email alerts</p>

                                <label class="checkbox-label">
                                    <input {%checked alert-telegram} class="chkbox" name="telegramon" type="checkbox">
                                    <span class="checkbox-custom rectangular"></span>
                                </label>
                                <p class="checkbox-text">Enable Telegram alerts</p>

                                <label class="checkbox-label">
                                    <input {%checked alert-slack} class="chkbox" name="slackon" type="checkbox">
                                    <span class="checkbox-custom rectangular"></span>
                                </label>
                                <p class="checkbox-text">Enable Slack alerts</p>

                                <label class="checkbox-label">
                                    <input {%checked alert-discord} class="chkbox" name="discordon" type="checkbox">
                                    <span class="checkbox-custom rectangular"></span>
                                </label>
                                <p class="checkbox-text">Enable Discord alerts</p>


                                <button name="alert-methods" type="submit" class="btn">Save</button>
                            </form>
                        </div>
                    </div>

                    <div class="panel panel-filled">
                        <div class="panel-heading">Callback alert settings</div>
                        <div class="panel-body">
                            <form class="form" method="post">
                                <input type=hidden hidden name="csrf" value="{session[csrfToken]}">
                                <label class="checkbox-label">
                                    <input {%checked alert-callback} class="chkbox" name="callbackon" type="checkbox">
                                    <span class="checkbox-custom rectangular"></span>
                                </label>
                                <p class="checkbox-text">Enable custom callback alert</p>
                                <div class="form-group">
                                    <label class="control-label" for="callback_url">Callback url</label>
                                    <small>ezXSS will post forward
                                        all reports in JSON format to the URL</small>
                                    <input class="form-control" name="callback_url"
                                        placeholder="https://example.com/callback.php" type="text"
                                        value="{%data callbackURL}">
                                </div>
                                <button name="callback-alert" type="submit" class="btn">Save</button>
                            </form>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </section>
</div>

<div class="modal fade" id="getChatId" role="dialog">
    <div class="modal-dialog" style="width:430px;">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal" type="button">&times;</button>
                <h3 class="m-b-xs">Get Telegram Chat ID</h3>
                <small>Start an chat with your bot to get chat id</small>
            </div>
            <div class="modal-body" id="getChatIdBody">
                Loading...
            </div>
            <div class="modal-footer">
                <button class="btn" data-dismiss="modal" type="button">Close</button>
            </div>
        </div>
    </div>
</div>